package com.travel.recommend.service.impl;

import com.travel.common.to.UserBehaviorWeightTo;
import com.travel.recommend.entity.RecommendParameterEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.Query;

import com.travel.recommend.dao.UserBehaviorWeightDao;
import com.travel.recommend.entity.UserBehaviorWeightEntity;
import com.travel.recommend.service.UserBehaviorWeightService;


@Service("userBehaviorWeightService")
public class UserBehaviorWeightServiceImpl extends ServiceImpl<UserBehaviorWeightDao, UserBehaviorWeightEntity> implements UserBehaviorWeightService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserBehaviorWeightEntity> page = this.page(
                new Query<UserBehaviorWeightEntity>().getPage(params),
                new QueryWrapper<UserBehaviorWeightEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 获取当前使用的配置
     * @return
     */
    @Override
    public UserBehaviorWeightEntity getNowUserBehaviorWeight() {

        return this.baseMapper.selectOne(new QueryWrapper<UserBehaviorWeightEntity>().eq("now_config",1));
    }

    /**
     * 获取当前使用的配置
     * @return
     */
    @Override
    public UserBehaviorWeightTo getUserBehaviorWeight() {
        UserBehaviorWeightEntity entity = this.baseMapper.selectOne(new QueryWrapper<UserBehaviorWeightEntity>().eq("now_config", 1));
        UserBehaviorWeightTo to = new UserBehaviorWeightTo();
        BeanUtils.copyProperties(entity,to);
        return to;
    }

}